package com.org.service.impl;

import com.org.entity.Poem;
import com.org.mapper.PoemMapper;
import com.org.service.PoemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Random;

/**
 * @author Rainy-Heights
 * @version 1.0
 * @Date 2023/3/8 10:16
 */
@Service
public class PoemServiceImpl implements PoemService {
    @Resource
    PoemMapper poemMapper;

    @Override
    public List<Poem> getContentPoems() {
        return poemMapper.selectAllPoem();
    }

    //随机展现诗歌
    @Override
    public Poem getPoem() {
        Random random=new Random();
        int id=random.nextInt(poemMapper.getPoemCount()-1)+1;
        return poemMapper.getPoem(id);
    }

    @Override
    public int addPoem() {
        return 0;
    }

    @Override
    public int deletePoem(int id) {
        return poemMapper.deletePoem(id);
    }

    @Override
    public int getPoemCount() {
        return poemMapper.getPoemCount();
    }
}
